<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>商品类别</title>
    <link href="__STATIC__/admin/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="__STATIC__/admin/css/style.css"/>
    <link href="__STATIC__/admin/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="__STATIC__/admin/font/css/font-awesome.min.css"/>
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace-ie.min.css"/>
    <![endif]-->
    <script src="__STATIC__/admin/js/jquery-1.9.1.min.js"></script>
    <script src="__STATIC__/admin/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="__STATIC__/admin/assets/js/typeahead-bs2.min.js"></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.min.js"></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/js/lrtk.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/assets/laydate/laydate.js" type="text/javascript"></script>
    <style>
        .table.table-bordered tbody tr td{
            text-align: left;
        }
    </style>
</head>

<body>
<div class="crumbs">
    <ul>
        <li>
            <a class="active" href="javascript:;">商品类别列表</a>
        </li>
    </ul>
</div>
<div class="page-content clearfix">
    <div class="administrator">
        <div class="d_Confirm_Order_style">

            <!--操作-->
            <div class="border clearfix">
                <span class="l_f">
                    <a href="{:url('category/set')}" class="btn btn-warning"><i class="fa fa-plus"></i> 添加类别</a>
                </span>
            </div>
            <!--管理员列表-->
            <div class="clearfix">
                <div class="table_menu_list">

                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th width="80px">类别名称</th>
                            <th width="250px">父类别</th>
                            <th width="100px">排序</th>
                            <th width="70px">状态</th>
                            <th width="200px">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach $categories as $item}
                        <tr data-level="{$item.level}">
                            <td class="title">{:str_repeat('-',$item.level*4)}{$item.title}</td>
                            <td>{$item.pid}</td>
                            <td>{$item.sort}</td>
                            <td>
                                {if condition="$item.status==1"}
                                <span class="label label-success radius">已启用</span>
                                {else /}
                                <span class="label label-error radius">已停用</span>
                                {/if}
                            </td>
                            <td>
                                <a title="编辑" href="{:url('category/set',['id'=>$item.id])}"
                                   class="btn btn-xs btn-info">
                                    <i class="fa fa-edit bigger-120"></i>
                                </a>
                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>
</body>
</html>
<script>
    $('.title').on('click',function () {
        //获取用户单击的列所在的行
        var currentTr=$($this).parent();
        //获取用户单击的level的值
        var currentLevel=$(currentTr).data('level');

        //获取单击行后面的所有行
        var trs=$(currentTr).nextAll('tr');
        $.each(trs,function (index,item) {
            var level=$(item).data('level');
            if(level<=currentLevel){
                return false;
            }
            $(item).toggle(200);
        })
    })
</script>